package com.gduf.lsm.mapper;

import com.gduf.lsm.common.annotation.AutoFill;
import com.gduf.lsm.common.enums.OperationType;
import com.gduf.lsm.entity.JoinCultural;
import com.gduf.lsm.pojo.vo.JoinCulturalShowVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 操作joinCultural相关数据接口
*/
@Mapper
public interface JoinCulturalMapper {

    /**
     * 新增
     * @param joinCultural
     * @return
     */
    @AutoFill(value = OperationType.INSERT)
    int insert(JoinCultural joinCultural);

    /**
     * 删除
     * @param id
     * @return
     */
    int deleteById(Integer id);

    /**
     * 修改
     * @param joinCultural
     * @return
     */
    @AutoFill(value = OperationType.UPDATE)
    int updateById(JoinCultural joinCultural);

    /**
     * 根据ID查询
     * @param id
     * @return
     */
    @Select("select * from join_cultural where id=#{id}")
    JoinCultural selectById(Integer id);

    /**
     * 查询所有
     * @param joinCultural
     * @return
     */
    List<JoinCultural> selectAll(JoinCultural joinCultural);

    /**
     * 分页条件查询
     * @param joinCultural
     * @return
     */
    List<JoinCulturalShowVO> selectPageQuery(JoinCultural joinCultural);

    /**
     * 查询老人是否报名活动，此处可以直接看用户是否有在里面，有则有报名
     * 注意为非已取消状态
     * @param culId
     * @param userId
     * @return
     */
    @Select("select * from join_cultural where user_id=#{userId} and cul_id=#{culId} and status!='已取消'")
    List<JoinCultural> selectByCulIdAndUserId(Integer culId, Integer userId);

    /**
     * 具体查询老人是否报名
     * 注意为非”已取消“状态
     * @param culId
     * @param userId
     * @param oldId
     * @return
     */
    @Select("select * from join_cultural where cul_id=#{culId} and user_id=#{userId} and old_id=#{oldId} and status!='已取消'")
    JoinCultural selectByCulIdAndUserIdAndOldId(Integer culId, Integer userId, Integer oldId);
}